/**
 * Copyright (c) 2009 blurredVision
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 * associated documentation files (the "Software"), to deal in the Software without restriction, 
 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or 
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 
 * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 
 * OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
#ifndef __GUI_TABLE_H__
#define __GUI_TABLE_H__

#pragma once

#include "Component.h"
#include "ISelectable.h"
#include "TableItem.h"

#include <vector>

namespace gui {

/**
 * \ingroup coreGUI
 *
 * The Table interface.<br>
 * Creates a GUI Table. Rows can be added via addItem().<br>
 * The default column width is 10px. It can be changed per column by calling setWidth().
 *
 * \date 04-13-2007
 *
 * \author juckel
 *
 */
class GUI_EXPORT Table :
	public Component, 
	public ISelectable
{
public:
	/// Create a table with the specified number of columns
	Table(unsigned int numColumns);
	virtual ~Table(void);

	/// Add a row to the table
	void addItem(TableItem *item);

	/// Delete all the items from the table
	void clear();

	/// Set the width of a specific column
	void setColumnWidth(unsigned int columnIndex, int width);

	/// Return the selected TableItem. NULL if no item is selected
	TableItem* getSelectedItem() const;

	virtual void draw();

	virtual inline const int getGUIType() const { return GUI_TABLE; }

protected:
	virtual void onMousePressed(const MouseEvent &me);
	/// Resize the table to include all items
	void resize();

	unsigned int m_uiNumColumns;
	int         *m_pColumnWidth;
};

} // namespace

#endif
